﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace NuMvvm.Services
{
    public class WindowService : IWindowService
    {
        public IWindow CurrentWindow
        {
            get
            {
                return Window.Current;
            }
        }

        public IDialogWindow CurrentDialog
        {
            get
            {
                return Window.Current as IDialogWindow;
            }
        }

        public void Show(object window)
        {
            var w = (Window)Activator.CreateInstance((Type)window);
            w.Show();
        }

        public void Show(object window, object arg)
        {
            var w = (Window)Activator.CreateInstance((Type)window, new object[] { arg });
            w.Show();
        }

        public bool? ShowDialog(object window)
        {
            var w = (Window)Activator.CreateInstance((Type)window);
            return w.ShowDialog();
        }

        public bool? ShowDialog(object window, object arg)
        {
            var w = (Window)Activator.CreateInstance((Type)window, new object[] { arg });
            return w.ShowDialog();
        }
    }
}
